class Solution(object):
    def permute(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        n = len(nums)
        res,path = [],[]
        def dfs(i):
            if i == n:
                res.append(path[:])
                return
            for j in range(0,n):
                if nums[j] not in path:
                    path.append(nums[j])
                    dfs(i + 1)
                    path.pop()
        dfs(0)
        return res